package com.lsl.builder_pattern.practice.practice2;


/**
 * @author Zed
 * @description
 * @date 2022/11/27 13:30
 */
public class TextBuilder extends Builder {
    StringBuffer stringBuffer = new StringBuffer();


    @Override
    public void close() {
        stringBuffer.append("===============");
    }

    @Override
    protected void buildTitle(String title) {
        stringBuffer.append("============\n");
        stringBuffer.append("[").append(title).append("]\n");
        stringBuffer.append("\n");
    }

    @Override
    protected void buildString(String str) {
        stringBuffer.append('♢').append(str).append("\n");
        stringBuffer.append("\n");
    }

    @Override
    protected void buildItems(String[] items) {
        for (int i = 0; i < items.length; i++) {
            stringBuffer.append("*").append(items[i]).append("\n");
        }
        stringBuffer.append("\n");
    }

    @Override
    protected void buildClose() {
        stringBuffer.append("===============");
    }

    public String getResult() {
        return stringBuffer.toString();
    }
}
